Fix activity feed pagination error in getChallengeFeed#136
Open
prazgaitis wants to merge 2 commits into
Open
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Replace .collect() calls with bounded .take() reads inside the paginated getChallengeFeed query. Convex only allows a single paginated query per function execution; .collect() on larger result sets can internally trigger paginated reads, conflicting with the explicit .paginate() call on the activities table. Changes: - follows query: .collect() → .take(1000) - likes count per activity: .collect() → .take(500) - comments count per activity: .collect() → .take(500) Fixes Sentry #7280439142 https://claude.ai/code/session_01Q598Pr5xHFqAS7PAU1GCNA
9a2e72c to
bcda35a
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes Sentry error #7280439142 where
getChallengeFeedthrows "multiple paginated queries" error. The query was using.paginate()for the main feed while also calling.collect()within the hydration loop to count likes and comments. Convex only allows a single paginated query per function execution, and.collect()can internally trigger pagination for larger result sets.Changes:
.collect()with.take(500)for likes and comments counting in the activity hydration loop.collect()with.take(1000)for the follows query as a defensive measure.take(n)avoids the internal pagination mechanism that.collect()can triggerThe limits chosen (1000 for follows, 500 for likes/comments) are generous for real-world usage and stay within Convex's per-function document read limits.
Testing
Notes
This is a targeted fix for the pagination constraint violation. The bounded
.take()calls replace unbounded.collect()calls that were causing the error, while maintaining sufficient capacity for typical activity feed usage patterns.https://claude.ai/code/session_01Q598Pr5xHFqAS7PAU1GCNA